package cn.wolfcode.wolf2w.job;


import cn.wolfcode.wolf2w.redis.IStrategyStatisVoRedisService;
import cn.wolfcode.wolf2w.service.IStrategyService;
import cn.wolfcode.wolf2w.util.RedisKeys;
import cn.wolfcode.wolf2w.vo.StrategyStatisVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;

import java.util.List;

/*@Component*/
public class RedisDataPersistenceJob {

    @Autowired
    private IStrategyStatisVoRedisService strategyStatisVoRedisService;
    @Autowired
    private IStrategyService strategyService;

    @Scheduled(cron="0 25 22 * * ? *")
    public void redisDataPersistence(){
        System.out.println("--------------开始----------------");
        // strategy_statis_vo:*
        String pattern = RedisKeys.STRATEGY_STATIS_VO.join("*");
        List<StrategyStatisVO> vos = strategyStatisVoRedisService.getVOListByPattern(pattern);
        for (StrategyStatisVO vo : vos) {
            strategyService.updateStatisByVo(vo);
        }
        System.out.println("--------------结束----------------");

    }
}
